/*
 * PACKAGE NAME: com.jodinfo.outmirror.api.columndefine.controller
 * FILE    NAME: ColumnDefineDaoImpl.java
 * COPYRIGHT: Copyright(c) © 2016 heroj Company Ltd. All Rights Reserved
 */ 
package com.jodinfo.outmirror.api.columndefine.controller;

import java.math.BigInteger;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.hero.common.web.context.UserContext;
import com.hero.core.constant.SysConstant;
import com.hero.core.entity.ResponseEntity;
import com.jodinfo.outmirror.api.columndefine.entity.ColumnDefineEntity;
import com.jodinfo.outmirror.api.columndefine.service.ColumnDefineBizService;
import com.jodinfo.outmirror.api.columndefine.service.ColumnDefineQueryService;



@Controller
@RequestMapping(value = "/ColumnDefineAdmin")
public class ColumnDefineController  {
	
@Resource(name="columnDefineBizService")
private ColumnDefineBizService columnDefineBizService;

/**
*  list数据源
* 
* */
@RequestMapping(value = "/List")
@ResponseBody
public String ColumnDefineList(ColumnDefineEntity columnDefineEntity) {
	if(columnDefineEntity==null){
		columnDefineEntity = new ColumnDefineEntity();
		columnDefineEntity.setPageIndex(SysConstant.DEFAULT_PAGEINDEX);
		columnDefineEntity.setPageSize(SysConstant.DEFAULT_PAGESIZE);
	}
	columnDefineEntity.setCurrentUser(UserContext.getUser());
	String str = columnDefineBizService.queryListForPageColumnDefine(columnDefineEntity);
	return str;
}
/**
* ColumnDefineEntity List页面
* 
* */
@RequestMapping(value = "/ListPage")
public ModelAndView columnDefineListPage(ColumnDefineEntity columnDefineEntity,HttpServletRequest request) {
	
	return new ModelAndView(returnPath("columnDefineList"));
}
/**
* ColumnDefineEntity详细页 
* 
* */
@RequestMapping(value = "/EditPage")
public ModelAndView columnDefineEditPage(ColumnDefineEntity columnDefineEntity) {
	
	return new ModelAndView(returnPath("columnDefineAdd"));
}
/**
 * 查询ColumnDefineEntity
 * 
 * */
@RequestMapping(value = "/queryByID")
public @ResponseBody String findColumnDefineData(HttpServletRequest request) {
	String id = request.getParameter("id");
	ColumnDefineEntity columnDefineEntity =  columnDefineBizService.queryById(new BigInteger(id));
	return JSON.toJSONString(columnDefineEntity); 
}

/**
 * 保存或更新ColumnDefine 
 * 
 * */
@RequestMapping(value = "/saveColumnDefine")
public @ResponseBody String saveColumnDefineData(@RequestBody ColumnDefineEntity columnDefineEntity) {
	ResponseEntity rs = null;
	if(columnDefineEntity!=null){
		columnDefineEntity.setCurrentUser(UserContext.getUser());
		if(columnDefineEntity.getId()!=null){
			rs = columnDefineBizService.updateColumnDefine(columnDefineEntity);
		}else{
			rs = columnDefineBizService.addColumnDefine(columnDefineEntity);
		}
	}
	return JSON.toJSONString(rs);
}
/**
 * 导出ColumnDefineEntity
 * @author shensu
 * @date 2015-7-09  下午2:13:28
 * @return
 */
@RequestMapping(value = "/exportColumnDefineExcel")
public void exportColumnDefineExcel(ColumnDefineEntity columnDefineEntity,HttpServletResponse response) {
		columnDefineBizService.exportColumnDefine(columnDefineEntity, response);
}
/**
 * 定义
 * 
 */
private final String MODULE_PATH = "/columndefine/";

//返回路径
private String returnPath(String jspName) {
	return MODULE_PATH + jspName;
}
}
